import { Component, OnInit } from '@angular/core';
import {Position} from '../../../entity/position';
import {CompanyService} from '../../../service/company.service';
import {ActivatedRoute} from '@angular/router';

@Component({
  selector: 'app-edit-position',
  templateUrl: '../add-position/add-position.component.html',
  styleUrls: ['./edit-position.component.css', '../add-position/add-position.component.css', '../edit-info/edit-info.component.css']
})
export class EditPositionComponent implements OnInit {
  isEdit = true;
  position: any = new Position();
  constructor(
    public companyService: CompanyService,
    private route: ActivatedRoute
  ) {
    this.getPosition();
  }

  ngOnInit() {
  }
  editPosition() {
    this.companyService.editPosition(this.position);
  }
  getPosition() {
    const id = Number.parseInt( this.route.snapshot.paramMap.get('id'));
    this.companyService.findPositonOne(id)
      .subscribe(position => this.position = position);
  }

}
